<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang='zh-CN' xml:lang='zh-CN' xmlns='http://www.w3.org/1999/xhtml'>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta http-equiv="Content-Language" content="zh-CN"/>
        <meta name="robots" content="index, follow" />
        <link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico" />
        <title>氿上网</title>
        {$system_css}
        {$system_js}
    </head>
    <body>
        <div id="OSC_Screen">
            {include file="header.html"}
            <div id="OSC_Content" class='CenterDiv'>
                {include file='user_nav.html'}
                {include file="message.html"}
                <div class="MainForm" id="reg_page">
                    <table width="100%" cellspacing="0" style="border:1px solid #ccc;">
                        <thead style="border:1px solid #ccc;">
                            <tr >
                                <th width="20%" style="border:1px solid #ccc;">产品名称</th>
                                <th width="20%" style="border:1px solid #ccc;">产品图片</th>
                                <th style="border:1px solid #ccc;">添加时间</th>
                                <th style="border:1px solid #ccc;">操作</th>
                            </tr>
                        </thead>
                        <tbody style="border:1px solid #ccc;">
                            {foreach from=$goods_list item=list}
                            <tr class="goods_div_{$list.id}">
                                <td  style="border:1px solid #ccc;" width="30%"><a href="{$list.goods_url}" target="_blank">{$list.name}</a></td>
                                <td style="border:1px solid #ccc;" ><a href="{$list.goods_url}" target="_blank"><img src="{$list.goods_image}" width="100" height="100"/></a></td>
                                <td style="border:1px solid #ccc;" >{$list.add_time|date}</td>
                                <td style="border:1px solid #ccc;" >

                                    {if $operate_type == 'onsale'}
                                    <a href="javascript:void(0);" class="operate" name="downsale" title="{$list.name}" id="{$list.id}">下架</a> | 
                                    {/if}

                                    {if $operate_type == 'downsale' || $operate_type=='recycle'}
                                    <a href="javascript:void(0);" class="operate" name="onsale" title="{$list.name}" id="{$list.id}">上架</a> | 
                                    {/if}

                                    {if $operate_type == 'onsale' || $operate_type=='downsale'}
                                    <a href="{$site_url}shop/seller/goods/edit/{$list.id}">编辑</a> | 
                                    {/if}

                                    <a href="javascript:void(0);" class="delete" title="{$list.name}" id="{$list.id}">删除</a>

                                    <p class="msg_{$list.id}" style="color:red"></p>
                                </td>
                            </tr>  
                            {/foreach}
                        </tbody>
                        <tfoot><tr><td colspan="3">{$page}</td></tr></tfoot>
                    </table>

                    <div class='clear'></div>
                </div>

            </div>
            <div class='clear'></div></div>
        <div class='clear'></div>
        {include file="footer.html"}
        </div>
        <script type="text/javascript">
            $(function(){
              
                $('.delete').click(function(){
                    var title = $(this).attr('title');
                    var answer = confirm('你确定要删除-'+title+'-吗？');
                    var id = $(this).attr('id');
                    if (answer){
                        $.ajax({
                            url:'/shop/ajax/delete_goods/'+id,
                            type:'POST',
                            data:'id='+id,
                            success:function(data){
                                $(".msg_"+id).show().html(data).fadeOut(2000);
                                if(data == '删除成功' || data=='产品加入回收站'){
                                    $('.goods_div_'+id).remove();
                                }
                            }
                        });
                    }
                });
                
                $('.operate').click(function(){
                    var title = $(this).attr('title');
                    var answer = confirm('你确定要操作-'+title+'-吗？');
                    var act = $(this).attr('name');
                    var id = $(this).attr('id');
                    if (answer){
                        $.ajax({
                            url:'/shop/ajax/operate_goods/'+id,
                            type:'POST',
                            data:'id='+id+'&act='+act,
                            success:function(data){
                                $(".msg_"+id).show().html(data).fadeOut(2000);
                                if(data == '操作成功'){
                                    $('.goods_div_'+id).remove();
                                }
                            }
                        });
                    }
                });
            });
            
        </script>
    </body>
</html>
